﻿CREATE TABLE Users(

    UserId smallint NOT NULL IDENTITY(1,1) PRIMARY KEY,
    Email varchar(128) NOT NULL,
    Fullname varchar(32) NOT NULL,
    Password nvarchar(128) NOT NULL
)
GO
CREATE TABLE Product(

    ProductId int NOT NULL IDENTITY(1,1) PRIMARY KEY,
    ProductName nvarchar(128) NOT NULL,
    ProductCode varchar(32) ,
    ImageThumb nvarchar(128) ,
    Image nvarchar(128) ,
    Wantary tinyint ,
    Price int ,
    Discount tinyint ,
    Description nvarchar(max) ,
    CategoryId int NOT NULL,
    ManufacturerId int NOT NULL
)
GO
CREATE TABLE Category(

    CategoryId int NOT NULL IDENTITY(1,1) PRIMARY KEY,
    CategoryName nvarchar(128) NOT NULL,
    Description nvarchar(256) 
)

CREATE TABLE Manufacturer(

    ManufacturerId int NOT NULL IDENTITY(1,1) PRIMARY KEY,
    ManufacturerName nvarchar(128) NOT NULL,
    ManufacturerLogo varchar(128) ,
    Description nvarchar(256) 
)
GO
CREATE TABLE Introduction(

    Title nvarchar(256) NOT NULL,
    Content nvarchar(max) NOT NULL,
    CompanyName nvarchar(256) ,
    Address nvarchar(256) ,
    Website varchar(128) 
)
GO
CREATE TABLE Feedback(

    FeedbackId int NOT NULL IDENTITY(1,1) PRIMARY KEY,
    Email varchar(128) NOT NULL,
    Title nvarchar(256) NOT NULL,
    Content nvarchar(max) NOT NULL,
    FeedbackDate datetime NOT NULL
)
GO
CREATE TABLE Contact(

    ContactLabel nvarchar(256) NOT NULL,
    ContactType tinyint NOT NULL,
    ContactDetail nvarchar(256) NOT NULL
)
GO
CREATE TABLE Config(

    WebsiteTitle nvarchar(128) NOT NULL,
    WebsiteName nvarchar(128) NOT NULL,
    WebsiteSlogan nvarchar(128) ,
    Banner nvarchar(128) ,
    Footer nvarchar(max) ,
    Visited int NOT NULL
)
GO

ALTER TABLE Product ADD CONSTRAINT FK_Product_Category FOREIGN KEY(CategoryId) REFERENCES Category(CategoryId) 
GO
ALTER TABLE Product ADD CONSTRAINT FK_Product_Manufacturer FOREIGN KEY(ManufacturerId) REFERENCES Manufacturer(ManufacturerId) 
GO
